package com.patelski.magic.service;

import com.patelski.magic.model.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.framework.EntityQuery;
import java.util.List;
import java.util.Arrays;

import javax.ejb.Remove;
import javax.ejb.Stateful;

@Name("cardList")
public class CardList extends EntityQuery {

	private static final String[] RESTRICTIONS = {
			"lower(card.cardName) like concat('%',lower(#{cardList.card.cardName}),'%')",
			"card.edition = #{cardList.card.edition}",
			"card.color = #{cardList.card.color}",
			"card.foil = #{cardList.card.foil}" };

	public Card card = new Card();

	@DataModel
	private List<Card> resultList;

	@Override
	public String getEjbql() {
		return "select card from Card card";
	}

	@Override
	public Integer getMaxResults() {
		return 100;
	}

	public Card getCard() {
		return card;
	}

	@Override
	public List<String> getRestrictions() {
		return Arrays.asList(RESTRICTIONS);
	}

	@Override
	public String getOrder() {
		return "card.cardName";
	}
	
}
